<html>
<head><meta charset="utf-8"><title>leak check and hrtb in chalk · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html">leak check and hrtb in chalk</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196639361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196639361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196639361">(May 06 2020 at 14:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> How would you represent the example under "Higher ranked trait obligations" here <a href="https://rustc-dev-guide.rust-lang.org/traits/hrtb.html" title="https://rustc-dev-guide.rust-lang.org/traits/hrtb.html">https://rustc-dev-guide.rust-lang.org/traits/hrtb.html</a> in Chalk</p>



<a name="196639994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196639994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196639994">(May 06 2020 at 14:11)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> do you mean this example?</p>
<div class="codehilite"><pre><span></span><code><span class="k">where</span><span class="w"> </span><span class="n">T</span><span class="w"> </span>: <span class="nc">for</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">isize</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>



<a name="196640239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196640239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196640239">(May 06 2020 at 14:13)</a>:</h4>
<p>I'm not sure what you mean by "represent" it</p>



<a name="196640279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196640279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196640279">(May 06 2020 at 14:14)</a>:</h4>
<p>certainly the goal <code>forall&lt;'a&gt; { Implemented(T: Foo&lt;&amp;'a usize&gt;) }</code> applies</p>



<a name="196642441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196642441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196642441">(May 06 2020 at 14:30)</a>:</h4>
<p>Oh</p>



<a name="196650916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196650916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196650916">(May 06 2020 at 15:24)</a>:</h4>
<p>Sorry, was on a call</p>



<a name="196650935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196650935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196650935">(May 06 2020 at 15:24)</a>:</h4>
<p>anyways</p>



<a name="196651273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651273">(May 06 2020 at 15:26)</a>:</h4>
<p>That example <em>wasn't</em> the one I was talking about</p>



<a name="196651281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651281">(May 06 2020 at 15:26)</a>:</h4>
<p><em>but</em></p>



<a name="196651438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651438">(May 06 2020 at 15:27)</a>:</h4>
<p>what is the difference between</p>
<div class="codehilite"><pre><span></span><code>fn want_hrtb&lt;T&gt;() where T : for&lt;&#39;a&gt; Foo&lt;&amp;&#39;a isize&gt; { ... }
</code></pre></div>


<p>and</p>
<div class="codehilite"><pre><span></span><code>fn want_hrtb&lt;&#39;a, T&gt;() where T : Foo&lt;&amp;&#39;a isize&gt; { ... }
</code></pre></div>



<a name="196651462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651462">(May 06 2020 at 15:27)</a>:</h4>
<p>And how would they be represented differently in Chalk</p>



<a name="196651794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651794">(May 06 2020 at 15:30)</a>:</h4>
<p>and this is the example I was talking about (minimized):</p>
<div class="codehilite"><pre><span></span><code>trait Foo&lt;X&gt; {}
trait Bar&lt;X&gt; {}
impl&lt;X,F&gt; Foo&lt;X&gt; for F where F : Bar&lt;X&gt; {}
</code></pre></div>



<a name="196651840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651840">(May 06 2020 at 15:30)</a>:</h4>
<p>with the goal: <code>Baz: for&lt;'a&gt; Foo&lt;&amp;'a isize&gt;</code></p>



<a name="196651911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196651911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196651911">(May 06 2020 at 15:31)</a>:</h4>
<p>Is that goal the same as <code>forall&lt;'a&gt; { Baz: Foo&lt;&amp;'a isize&gt; }</code></p>



<a name="196652681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196652681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196652681">(May 06 2020 at 15:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651462" title="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651462">said</a>:</p>
<blockquote>
<p>And how would they be represented differently in Chalk</p>
</blockquote>
<p>in the former case, <code>T</code> is a type that implements <code>Foo&lt;&amp;'a isize&gt;</code> for any <code>'a</code> (e.g., including <code>'a</code> that the callee might specify).</p>
<p>In the latter case, <code>T</code> is a type that implements <code>Foo&lt;&amp;'a isize&gt;</code> for some specific <code>'a</code> (that the caller specifies).</p>



<a name="196652861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196652861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196652861">(May 06 2020 at 15:38)</a>:</h4>
<p>easier to see maybe with types, which chalk supports, even if Rust does't (yet)</p>



<a name="196652893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196652893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196652893">(May 06 2020 at 15:38)</a>:</h4>
<p>i.e., <code>where for&lt;U&gt; T: PartialEq&lt;U&gt;</code>, would mean that <code>T</code> is a type that can be equated with <strong>any</strong> <code>U</code></p>



<a name="196652903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196652903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196652903">(May 06 2020 at 15:38)</a>:</h4>
<p>vs <code>where T: PartialEq&lt;U&gt;</code></p>



<a name="196653263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653263">(May 06 2020 at 15:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651911" title="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651911">said</a>:</p>
<blockquote>
<p>Is that goal the same as <code>forall&lt;'a&gt; { Baz: Foo&lt;&amp;'a isize&gt; }</code></p>
</blockquote>
<p>yes</p>



<a name="196653283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653283">(May 06 2020 at 15:41)</a>:</h4>
<p>Rust permits you to write the <code>for</code> in two (equivalent) places</p>



<a name="196653303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653303">(May 06 2020 at 15:41)</a>:</h4>
<p><code>for&lt;'a&gt; T: ...</code> and <code>T: for&lt;'a&gt; ...</code></p>



<a name="196653498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653498">(May 06 2020 at 15:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651462" title="#narrow/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk/near/196651462">said</a>:</p>
<blockquote>
<p>And how would they be represented differently in Chalk</p>
</blockquote>
<p>so <code>want_hrtb&lt;T&gt;</code> would have one generic parameter (in the root universe), <code>T</code>, and it would have a where clause <code>forall&lt;'a&gt; { FromEnv(T: Foo&lt;&amp;'a isize&gt;) }</code> in the environment</p>



<a name="196653529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653529">(May 06 2020 at 15:42)</a>:</h4>
<p>whereas the other would have <code>FromEnv(T: Foo&lt;&amp;'a isize&gt;)</code> in the environment, with no forall</p>



<a name="196653759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653759">(May 06 2020 at 15:44)</a>:</h4>
<p>This has been helpful</p>



<a name="196653767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653767">(May 06 2020 at 15:44)</a>:</h4>
<p>To get my bearing</p>



<a name="196653807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/leak%20check%20and%20hrtb%20in%20chalk/near/196653807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/leak.20check.20and.20hrtb.20in.20chalk.html#196653807">(May 06 2020 at 15:44)</a>:</h4>
<p>Here is the full chalk example:</p>
<div class="codehilite"><pre><span></span><code>    test!{
        program {
            trait Foo&lt;X&gt; {}
            trait Bar&lt;X&gt; {}

            impl&lt;X,F&gt; Foo&lt;X&gt; for F where F : Bar&lt;X&gt; {}

            struct Baz {}
            struct Ref&lt;&#39;a&gt; {}
            impl&lt;&#39;a&gt; Bar&lt;Ref&lt;&#39;a&gt;&gt; for Baz {}
        }

        goal {
            forall&lt;&#39;a&gt; { Baz: Foo&lt;Ref&lt;&#39;a&gt;&gt; }
        } yields {
            &quot;Unique; substitution [], lifetime constraints []&quot;
        }
    }
</code></pre></div>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>